package com.welsy.iter.vo.iter
{
	import com.welsy.iter.vo.iter.pattern.*;
	import com.welsy.iter.business.IterQNames;
	import packages.course.Element;
	
	[Bindable]	
	public class ElementVO extends CourseItem
	{
	  	public var elementId:String = "";		
		public var type:String = "";			
		public var title:String = "";		
		public var position:String = "0";
		public var notes:String = "";		
		public var navigationType:String = "0";		
		public var audioId:String = "0";
		public var fileId:String = "0";		
		public var fileName:String = "";		
		public var testID:String = "0";					
		  
      public function ElementVO() {
         
      }
      
      public function toString() : String
		{
		    var s : String = "Element[id=";
		    s += elementId;
		    s += ", title=";
		    s += title;
		    s += ", type=";
		    s += type;
		    s += ", filename=";
		    s += fileName;
		    s += " ]";
		    return s;
		}
      
      public function setProperties(item:XML):void {      	
		var elemPosition:String = item.child(IterQNames.qnElPosition); 
		var elemId:String = item.child(IterQNames.qnElElementID);						
		var elemTitle:String = item.child(IterQNames.qnTitle);
		var elemType:String = item.child(IterQNames.qnElType);
		var elemAudioID:String = item.child(IterQNames.qnElElementAudioID);
		var elemFileId:String = item.child(IterQNames.qnElElementFileID);
		var elemFileName:String = item.child(IterQNames.qnElElementFileName);
		var elemNotes:String = item.child(IterQNames.qnElElementNotes);
		var elemNavigationType:String = item.child(IterQNames.qnElElementNavigationType);
		var testId:String = item.child(IterQNames.qnTestID);
        
        this.elementId = elemId;			
		this.title = elemTitle;
		this.type = elemType;
		this.position = elemPosition;
		this.audioId = elemAudioID;
		this.fileId = elemFileId;
		this.fileName = elemFileName;
		this.notes = elemNotes;
		this.testID = testId;
		this.navigationType = elemNavigationType;		        
      }
      
      public function setPropertiesElement(element:Element):void {      	
     	var elemPosition:String = element.position;
		var elemId:String = element.elementId;					
		var elemTitle:String = element.title;
		var elemType:String = element.type;
		var elemAudioID:String = element.audioId;
		var elemFileId:String = element.fileId;
		var elemFileName:String = element.fileName;
		var elemNotes:String = element.notes;
		var elemNavigationType:String = element.navigationType;
		var testId:String = element.testID;
        
        this.elementId = elemId;			
		this.title = elemTitle;
		this.type = elemType;
		this.position = elemPosition;
		this.audioId = elemAudioID;
		this.fileId = elemFileId;
		this.fileName = elemFileName;
		this.notes = elemNotes;
		this.testID = testId;
		this.navigationType = elemNavigationType;	        
      }
      
      override public function iterator():ICourseIterator {
         
         return new NullIterator();
      }
      
      //ricarica l'elmento nel caso in cui sia già stato caricato
      public function reload(el:ElementVO):Boolean {
         if (this.elementId == el.elementId)
         	return true
         else
         	return false
      }

	}
}